<div style="padding:0" align="left">
	{if $baners}
        {foreach from=$baners item=baner}
            <div id="home_banner_{$baner.stt}" {if $baner.stt>1}style="display:none"{/if}>
                {if $baner.type==1}
                    <embed width="790" height="250" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" quality="high" src="{$baner.path}"/>
                {else}
                	{if $baner.url}<a href="{$baner.url}" style="margin:0;padding:0;display:block" target="_blank">{/if}
                    <img width="790" height="250" border="0" src="{$baner.path}" alt=""/>
                    {if $baner.url}</a>{/if}
                {/if}
            </div>
        {/foreach}
    {/if}
    
{if $baners}
    <div style="width:790px;position:relative">
        <div class="fr" style="position:absolute;top:-33px;right:18px">
            {foreach from=$baners item=baner}
            <div class="hb_btn{if $baner.stt==1}_active{/if} fl" id="hb_btn{$baner.stt}" onclick="home_banner_show({$baner.stt});">
                {$baner.stt}
            </div>
            {/foreach}
        </div>
    </div>
	{if $max>1}	
  		<script>
		 var cur_next_banner = 2;
		
			 var max_home_banner = {$max};
			 var h_banner		 = {$h_banner};
			 
			 var hb_timer		 = 15000;
			 
			 {literal}
			 if(typeof(h_banner[1]) != 'undefined')
			 {
				hb_timer		 = parseInt(h_banner[1]);
			 }
			
			 function home_banner_show_next(){
				if(max_home_banner > 1){
					var pr_g;
					hb_timer		 = 15000;
					
					if(typeof(h_banner[cur_next_banner]) != 'undefined')
					{
						hb_timer		 = parseInt(h_banner[cur_next_banner]);
					}
					
					if(cur_next_banner>1){
						pr_g = cur_next_banner - 1;
					}
					else{
						pr_g = max_home_banner;
					}
					
					jQuery('#hb_btn'+pr_g).removeClass('hb_btn_active').addClass('hb_btn');
					jQuery('#hb_btn'+cur_next_banner).removeClass('hb_btn').addClass('hb_btn_active');
					
					jQuery('#home_banner_'+pr_g).hide()
					jQuery('#home_banner_'+cur_next_banner).show();
					
					cur_next_banner++;
					if(cur_next_banner>max_home_banner){
						cur_next_banner = 1;
					}
					
					delay_next = setTimeout("home_banner_show_next()", hb_timer);
				}
			}
			
			function home_banner_show(stt){
				var pr_g;
					
				if(cur_next_banner>1){
					pr_g = cur_next_banner - 1;
				}
				else{
					pr_g = max_home_banner;
				}
				
				hb_timer		 = 15000;
					
				if(typeof(h_banner[stt]) != 'undefined')
				{
					hb_timer		 = parseInt(h_banner[stt]);
				}
				
				if (window.delay_next)
						clearTimeout(delay_next);
						
				if(stt != pr_g)
				{
					jQuery('#hb_btn'+pr_g).removeClass('hb_btn_active').addClass('hb_btn');
					jQuery('#hb_btn'+stt).removeClass('hb_btn').addClass('hb_btn_active');
					
					jQuery('#home_banner_'+pr_g).hide()
					jQuery('#home_banner_'+stt).show();
					
					cur_next_banner = stt+1;
					if(cur_next_banner>max_home_banner){
						cur_next_banner = 1;
					}
				}
				
				delay_next = setTimeout("home_banner_show_next()", hb_timer);
			 }
			 {/literal}
			 delay_next = setTimeout("home_banner_show_next()", hb_timer);
	 	</script>
     {/if}
{/if}
    {if $is_admin}
        {$begin_form}
  <div style="cursor:pointer;margin:10px 0" onclick="jQuery('#admin_home_banner').toggle();"><strong>Quản lý banner</strong></div>
  <div style="margin:10px 0" id="admin_home_banner" class="hide">
    {$msg}<br />
        
    <strong>Up Banner:  </strong>
    <input type="file" name="banner"/> <select name="hb_update">{$hb_option}</select>
  	<br />
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>Ảnh</strong> 790x250...( .gif , .jpg ); <b>Flash</b>   790x250... ( .swf )
	<br /><br />
    <b>Url:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="url" value=""/> <br /> 
	<b>Thời gian:</b>&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="sec" value="15"/> <input type="submit" value="Cập nhật"/>
	            
            
            
            <table cellpadding="5" cellspacing="1" width="100%" bgcolor="#cccccc">
            	<tr bgcolor="#FFFFFF">
                	<th colspan="6" align="left" style="padding:3px">
                      Danh sách các Banner</th>
                </tr>
                <tr bgcolor="#FFFFFF">
                  <td><strong>STT</strong></td>
                  <td><strong>Vị trí</strong></td>
                  <td><strong>Kiểu</strong></td>
                  <td width="51%"><strong>Url</strong></td>
                  <td><strong>Thời gian</strong></td>
                  <td align="center"><strong>Thao tác</strong></td>
                </tr>
                {foreach from=$baners item=baner}
                    <tr bgcolor="#FFFFFF">
                      <td width="7%">{$baner.stt}</td>
                      <td width="8%">{$baner.name}</td>
                      <td width="8%">{if $baner.type==1}Flash{else}Ảnh{/if}</td>
                      <td>{$baner.url}</td>
                      <td width="9%">{$baner.time} s</td>
                      <td width="7%" align="center"><a href="{$baner.del}" onclick="return confirm('Bạn có chắc chắn muốn xóa không?');">Xóa</a></td>
                    </tr>
                {/foreach}
            </table>
  </div>
        {$end_form}
    {/if}
</div>